import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDESelectByKeyAction } from './ipsdeselect-by-key-action';
import { PSDEActionImplBase } from './psdeaction-impl-base';
import { IPSDEDataQuery } from '../ds/ipsdedata-query';

export class PSDESelectByKeyActionImpl extends PSDEActionImplBase implements IPSDESelectByKeyAction {
  get actionHolder(): 1 | 2 | 3 {
    return this.M.actionHolder;
  }

  protected psdedataquery: IPSDEDataQuery | null = null;

  getPSDEDataQuery(): IPSDEDataQuery | null {
    if (this.psdedataquery != null) return this.psdedataquery;
    const value = this.M.getPSDEDataQuery;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdedataquery = ipsdataentity.findPSDEDataQuery(value);
    }
    return this.psdedataquery;
  }

  get psDEDataQuery(): IPSDEDataQuery | null {
    return this.getPSDEDataQuery();
  }

  getPSDEDataQueryMust(): IPSDEDataQuery {
    const value = this.getPSDEDataQuery();
    if (value == null) {
      throw new Error('未指定实体数据查询');
    }
    return value;
  }

  get cls(): string {
    return 'PSDESelectByKeyActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.action.IPSDESelectByKeyAction') return true;
    return super.instanceof(cls);
  }
}
